const express=require('express')
const router= express.Router();
const db=require('../../utils/db')
const upload=require('../../utils/multer');

router.post('/bianji', function (req, res) {
  let mysql = `UPDATE user SET user_name='${req.body.name}',user_tel='${req.body.phone}',user_address='${req.body.address}',user_company='${req.body.Stores}',user_img='${req.body.imgURL}'  WHERE user_id ='${req.body.number}'`
  db(mysql, null, function (err, data) {
    if (err) {
      return res.json({
        code: 500,
        msg: '修改失败，请稍后重试'
      })
    }
    res.json({
      code: 200,
      msg: '修改成功'
    })
  })
})

// 上传照片
router.post('/upload', upload.single('file'), function (req, res) {
  res.send({ code: 200, userimgurl: req.file.filename });
});

module.exports = router